ExpressのError Handling
docs
#WIP
https://chaika.hatenablog.com/entry/2020/11/16/083000
routing部分でthrowすると、自分でhandlingしなくても自動で500を返す
code:ts
app.get('/', (req, res) => {
throw new Error('test');
});
app.listen(3030);
code:response
HTTP/1.1 500 Internal Server Error
...
1つ1つのEndpointで起きたerrorって一箇所で書くべきなのか?
特にすべて同じことをやっている場合
/mrsekut-book-483996937X/249
routing部分のerror handlerは結局、どういうstatus codeを返すか?のような話になるので、
defaultで設定したり、
何らかのlibraryを使ったほうが楽になる
だから、custom error sub classを自分で作る必要はないかも
@hapi/boom
https://github.com/hapijs/boom
make-error
https://github.com/JsCommunity/make-error
https://expressjs.com/ja/guide/error-handling.html
https://chaika.hatenablog.com/entry/2020/11/16/083000
https://note.com/shift_tech/n/n42b96d36f0cf
https://qiita.com/azujuuuuuun/items/f0be4a71aca2d92036aa
https://github.com/JsCommunity/make-error
https://tech-1natsu.hatenablog.com/entry/2018/06/30/165043
https://qiita.com/nyandora/items/cd4f12eb62295c10269c
https://expressjs.com/ja/advanced/best-practice-performance.html